<?php
	session_start();
	include "include.php";
	mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die(mysql_error());
	mysql_select_db(DB_NAME);
?>
<html>
<head>
<title><?php echo $SITE_TITLE ?> - Player Detail</title>
<link rel="stylesheet" type="text/css" href="main.css" />
<script src="http://www.wowhead.com/widgets/power.js"></script>
</head>
<div id="container">
<div id="top">
<h1><?php echo $SITE_TITLE ?> - <?php echo ucwords(get_player_name($_GET["players_id"])) ?></h1>
</div>
<div id="leftnav">
<?php include "leftnav.php" ?>
</div>
</p>
<div id="content">
<?php
		if(!get_user_rights(RIGHTS_USER)) {
			echo "You do not have permission to access this resource<br><a href=\"" . $SITE_URL . "\">Return to homepage</a>";
			complete_page_html();
			exit;
		}
		if(!get_user_rights(RIGHTS_OFFICER) && $_GET["players_id"] != get_player_id_from_user_id()) {
			echo "You do not have permission to access this resource<br><a href=\"" . $SITE_URL . "\">Return to homepage</a>";
			complete_page_html();
			exit;
		}
?>
<table class="loots">
	<tr><th>Loot</th><th>Date</th><th>Loot Type</th><th>Edit</th></tr>
<?php
	$sql = "SELECT * from loots WHERE loots.players_id = " . $_GET["players_id"] . ";";
	$result = mysql_query($sql);
	while($myrow = mysql_fetch_row($result)) {
		echo "<tr>";
		echo "<td><a href=\"http://www.wowhead.com/?item=" . $myrow[3] . "\">" . get_item_name($myrow[3]) . "</a></td><td>" . date("M j Y h:i:s A",$myrow[2]);
		if($myrow[4] == 0) {
			echo "</td><td>Normal Pick</td><td><a href=\"edit_loot.php?loots_id=" . $myrow[0] . "\">Edit</a></td>";
		}
		else {
			echo "</td><td>Rot Pick</td><td><a href=\"edit_loot.php?loots_id=" . $myrow[0] . "\">Edit</a></td>";
		}
		echo "</tr>";
	}
?>
</table>
 </div>
<div id="footer">
<?php include "footer.php" ?>
</div>
</div>
</body>
</html>